<%--
  Created by IntelliJ IDEA.
  User: qiwenyong
  Date: 2024/10/23
  Time: 14:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/alert.min.js"></script>
    <script>
        //    $('.alert').on('click', function () {
        //      $.alert('成功');
        //    });
        $(function(){

            $('.del').on('click', function () {
                $.confirm('确认要删除吗？', function (isConfirm) {
                    if (isConfirm) {
                        $.alert('确认');
                    } else {
                        $.alert('取消');
                    }
                });
            });

        });

    </script>
</head>
<body>

<div style="padding:0px; margin:0px;">
    <ul class="breadcrumb" style="  margin:0px; " >
        <li><a href="#">商品管理</a></li>
        <li>商品列表</li>
    </ul>
</div>
<div class="row alert alert-info" style="margin:5px 0px 5px 0px; padding:3px;">
    <form class="form-inline" action="${pageContext.request.contextPath}/ProductListServlet" method="post">
        <div class="form-group">
            <input type="text" name="name" value="${pageUtil.t.name}" class="form-control" id="activename" placeholder="请输入商品名称">
        </div>
        <div class="form-group">
            <select name="category" class="form-control">
                <option value="">--请选则商品类型---</option>
                <%--<option value="图书" ${pageUtil.t.category=='图书'?'selected':''}>图书</option>
                <option value="水果" ${pageUtil.t.category=='水果'?'selected':''}>水果</option>
                <option value="衣服" ${pageUtil.t.category=='衣服'?'selected':''}>衣服</option>
                <option value="手机" ${pageUtil.t.category=='手机'?'selected':''}>手机</option>--%>
                <c:forEach items="${categoryList}" var="c">
                    <option value="${c.id}" ${pageUtil.t.category==c.id?'selected':''}>${c.name}</option>
                </c:forEach>
            </select>
        </div>
        <div class="form-group">
            <label class="radio-inline">
            <input type="radio" value="1" name="state" ${pageUtil.t.state==1?'checked':''}>可售
            </label>
            <label class="radio-inline">
            <input type="radio" value="0" name="state" ${pageUtil.t.state==0?'checked':''}>禁售
            </label>
        </div>
        <input type="submit" class="btn btn-danger" value="查询"/>
<%--        <a class="btn btn-success" href="${pageContext.request.contextPath}/pages/product/save.jsp">增加</a>--%>
        <a class="btn btn-success" href="${pageContext.request.contextPath}/ProductInitAddServlet">增加</a>
    </form>
</div>
<div class="row" style="padding:15px; padding-top:0px;">
    <table class="table  table-condensed table-striped">
        <tr>
            <th>商品编号</th>
            <th>商品名称</th>
            <th>商品价格</th>
            <th>商品状态</th>
            <th>商品类型</th>
            <th>商品库存</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${pageUtil.data}" var="product" varStatus="stat">
            <tr>
                <td>${stat.count}</td>
                <td>${product.name}</td>
                <td>${product.price}</td>
                <td>${product.state==0?'禁售':'可售'}</td>
                <td>${product.category}</td>
                <td>${product.stock}</td>
                <td>
                    <a href="${pageContext.request.contextPath}/ProductFindByIdServlet?id=${product.id}">修改</a>
                    <a href="${pageContext.request.contextPath}/ProductDeleteByIdServlet?id=${product.id}">删除</a>
                </td>
            </tr>
        </c:forEach>

    </table>
    <nav aria-label="...">
        <ul class="pager">
            <li class="previous ${pageUtil.hasPre ? '':'disabled'}"><a href="${pageContext.request.contextPath}/ProductListServlet?pageNum=${pageUtil.hasPre ? pageUtil.pageNum-1 : pageUtil.firstPage}&name=${pageUtil.t.name}&category=${pageUtil.t.category}&state=${pageUtil.t.state}"><span aria-hidden="true">&larr;</span> Older</a></li>
            <li class="next  ${pageUtil.hasNext ? '':'disabled'}"><a href="${pageContext.request.contextPath}/ProductListServlet?pageNum=${pageUtil.hasNext ? pageUtil.pageNum+1 : pageUtil.pageNum}&name=${pageUtil.t.name}&category=${pageUtil.t.category}&state=${pageUtil.t.state}">Newer <span aria-hidden="true">&rarr;</span></a></li>
        </ul>
    </nav>
</div>
</body>
</html>
